package com.kaifamiao.month04.day08;

import java.util.Scanner;

public class Test {

    public static void main(String[] args) {
        System.out.println("输入字符串");
        Scanner in = new Scanner(System.in);
        String str = in.next();
        System.out.println(stringNoRepeat(str));

    }

    public static int stringNoRepeat(String str){
        int count = 0;
        int len = 0;
        for (int i = 0; i < str.length(); i++) {
            String s = str.substring(i, i+1);
            int end = str.indexOf(s, i + 1);
            if(end != -1 && len < (end - i)) {
                len = end - i;
            }
            if(end == -1) {
                count += end;
            }
        }
        if(count == -str.length()) {
            len = str.length();
        }
        return len;
    }
}
